package com.CoreryBlack.config;


import com.CoreryBlack.interceptors.TokenInterceptor;
import jakarta.servlet.http.WebConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.nio.file.Watchable;

/**
 * @Description WebConfig
 * @Author CoreryBlack
 * @Date 2024-09-22
 */

@Configurable
public class WebConfig implements WebMvcConfigurer {
//    @Autowired
//    private DemoInterceptor demoInterceptor;

    @Autowired
    private TokenInterceptor tokenInterceptor;




//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(demoInterceptor)
//                .addPathPatterns("/**")//设置拦截的请求路径
//                .excludePathPatterns("/login");//设置不拦截的请求路径
//    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册自定义拦截器对象
//        registry.addInterceptor(demoInterceptor).addPathPatterns("/**");




        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/login")
                .excludePathPatterns("/upload");
    }
}
